
TRIGGER PROCEDURE FOR WRITE OF ptsd_det OLD BUFFER OLD_ptsd_det.


{mfdeclre.i }
define new shared work-table wf_old_ptsd_det like ptsd_det.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "ptsd_det" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(ptsd_det), input "ptsd_det").

    if not can-find ( first dt_mstr where dt_table = "ptsd_det" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_ptsd_det ) then do:
        create wf_old_ptsd_det.
        if recid(wf_old_ptsd_det)= -1 then .
    end.
    
    buffer-copy old_ptsd_det to wf_old_ptsd_det no-error.

    for each dt_mstr no-lock where dt_table = "ptsd_det" and dt_type = "MOD" :
    
        case dt_field :

           when "ptsd_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_part, input ptsd_det.ptsd_part,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_sub_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_sub_part,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_vend" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_vend, input ptsd_det.ptsd_vend,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_pct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ptsd_det.ptsd_pct), input string(ptsd_det.ptsd_pct),
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_qty_min" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ptsd_det.ptsd_qty_min), input string(ptsd_det.ptsd_qty_min),
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_rmks" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_rmks, input ptsd_det.ptsd_rmks,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_userid, input ptsd_det.ptsd_userid,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_mod_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_ptsd_det.ptsd_mod_date), input string(ptsd_det.ptsd_mod_date),
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_user1, input ptsd_det.ptsd_user1,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd_user2, input ptsd_det.ptsd_user2,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").

            when "ptsd__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_ptsd_det.ptsd__qadc01, input ptsd_det.ptsd__qadc01,
                    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
                    input "", input "", input "", input "").
        end.
    end.
end.

{hkdttrans.i}
